<template>
  <div class="course-section">
    <h3>{{ sectionData.sectionName }}</h3>
    <p class="lesson" v-for="item in sectionData.courseLessons" :key="item.id" @click="handelAction(item)">
      <span>{{ item.theme }}</span>
      <van-icon v-if="item.canPlay" name="play-circle" size="15" />
      <van-icon v-else name="lock" size="15"/>
    </p>
  </div>
</template>

<script>
import { Icon } from 'vant'
export default {
  components: {
    VanIcon: Icon
  },
  name: 'CourseSectionAndLesson',
  props: {
    sectionData: {
      type: Object,
      required: true
    }
  },
  methods: {
    handelAction (item) {
      if (item.canPlay) {
        this.$router.push({ name: 'CourseVideo', params: { lessonId: item.id } })
      }
    }
  }

}
</script>

<style scoped>
.course-section {
  padding: 0 20px;
}
.lesson {
  display: flex;
  justify-content: space-between;
}
</style>
